package jmine.tec.web.wicket.cronExpression;

import bancosys.tec.exception.LocalizedMessageHolder;
import bancosys.tec.exception.MessageCreator;
import bancosys.tec.exception.MessageCreatorHelper;

/**
 * Enum for the optional component of the {@link CronExpressionComponent}.
 * 
 * @author Fabio Sakiyama
 * @created 11/11/2011
 */
public enum OptionalComponentsEnum implements MessageCreator {

    DAYS("jmine-tec.web.wicket.cronexpression.optional.components.days"),

    MONTHS("jmine-tec.web.wicket.cronexpression.optional.components.months"),

    WEEK_DAYS("jmine-tec.web.wicket.cronexpression.optional.components.weekdays");

    private final MessageCreator component;

    /**
     * Construtor.
     * 
     * @param componentKey - component's name.
     */
    private OptionalComponentsEnum(String componentKey) {
        this.component = MessageCreatorHelper.creator("jmine-tec-web-wicket-messages", componentKey, 0);
    }

    /**
     * @return the component
     */
    public LocalizedMessageHolder getComponent() {
        return this.component.create();
    }

    /**
     * Representação alfanumérica do enum.
     * 
     * @return nome do enum.
     */
    @Override
    public String toString() {
        return this.getComponent().getMessage();
    }

    /**
     * Return <code>true</code> if it's DAYS, <code>false</code> otherwise.
     * 
     * @return <code>true</code> if it's DAYS, <code>false</code> otherwise.
     */
    public boolean isDays() {
        return this.equals(DAYS);
    }

    /**
     * Return <code>true</code> if it's MONTHS, <code>false</code> otherwise.
     * 
     * @return <code>true</code> if it's MONTHS, <code>false</code> otherwise.
     */
    public boolean isMonths() {
        return this.equals(MONTHS);
    }

    /**
     * Return <code>true</code> if it's WEEK_DAYS, <code>false</code> otherwise.
     * 
     * @return <code>true</code> if it's WEEK_DAYS, <code>false</code> otherwise.
     */
    public boolean isWeekDays() {
        return this.equals(WEEK_DAYS);
    }

    /**
     * {@inheritDoc}
     */
    public LocalizedMessageHolder create(Object... arguments) {
        return this.component.create(arguments);
    }

    /**
     * {@inheritDoc}
     */
    public int getExpectedArguments() {
        return this.component.getExpectedArguments();
    }
}
